#include <bits/stdc++.h>
using namespace std;

namespace fuh{
    class Bit_map{
        size_t m_size;
        vector<int> _arr;
        public:
        Bit_map(size_t size =100)
        :m_size(size/32 +1)
        ,_arr(m_size,0)
        {

        }
        void set(size_t x)
        {
            size_t i = x/32;
            size_t j = x%32;
            _arr[i] |= (1<<j);
        }
        bool isExisted(size_t x)
        {
            size_t i = x/32;
            size_t j = x%32;
            return _arr[i] & (1<<j);
        }
        void reset(size_t x)
        {
            size_t i = x/32;
            size_t j = x%32;
            _arr[i] &= ~(1<<j);
        }
    };
    template <size_t size = 1000>
    class TwoBitSet{
        Bit_map m_bit1;
        Bit_map m_bit2;
        public:
        bool set(size_t x)
        {
            if(m_bit2.isExisted(x)==false)
            {
                m_bit2.set(x);
                return 1;
            }
            else if(m_bit1.isExisted(x)==false && m_bit2.isExisted(x)==true)
            {
                m_bit1.set(x);
                m_bit2.reset(x);
                return 1;
            }
            return 0;
        }
    };
};





